﻿/// Write a program that reads a text file and inserts line numbers in front of each of its lines.
/// The result should be written to another text file.

using System;
using System.IO;


namespace c_sh_II_lek_6_files
{
    class zad1
    {
        static void Main()
        {
            string soureceFile = @"..\..\zad3.cs";
            string lineNum = @"..\..\zad3_lineNum.cs";
            string line;
            int n = 0;

            if (File.Exists(lineNum))
            {
                File.Delete(lineNum);
            }

            using (StreamWriter sw = new StreamWriter(lineNum))
            {
                using (StreamReader sr = new StreamReader(soureceFile))
                {
                    line = sr.ReadLine();
                    while (line != null)
                    {
                        sw.WriteLine(n + " " + line);
                        line = sr.ReadLine();
                        n++;
                    }
                }
            }
        }
    }
}
